#include <bits/stdc++.h>
using namespace std;

// 排序的要求
enum order{ID, NAME, AGE, SCORE};

class student
{
public:
    int ID;
    string name;
    int age;
    float score;

    // 构造函数
    student(int id, string n, int a, float s)
    :age(a), name(n), ID(id), score(s){}
};

// 自定义比较器函数
template <class T>
bool cmp(T a, T b)
{
    return a<b;
}

// 函数对象：实现了operator()的类的对象
template <class T>
class cmp2
{
public:
    bool operator()(T a, T b)
    {
        return a<b;
    }
};

// 专用于学生类比较的函数对象
template <class T>
class cmp3
{
public:
    int order;
    // cmp3(int o):order(o){}

    bool operator()(const T &s1, const T &s2)
    {
        // 按照对象要求的对比参数来排序
            return s1.score < s2.score;
        // switch(order)
        // {
        // case ID:
        //     return s1.ID < s2.ID; break;
        // case NAME:
        //     return s1.name < s2.name; break;
        // case AGE:
        //     return s1.age < s2.age; break;
        // }
        
    }
};

void showInfo(const student &s)
{
    cout << "学号:" << s.ID << " ";
    cout << "姓名:" << s.name << " ";
    cout << "年龄:" << s.age << " ";
    cout << "分数:" << s.score << endl;
}

int main(int argc, char const *argv[])
{
    // 算法库自带的比较器： less<int>
    // less: 模板
    // less<int>: 函数符
    // 函数符：普通的函数、函数对象、Lambda表达式
    //priority_queue<int, vector<int>, less<int> > pq;
    //priority_queue<int, vector<int>, greater<int> > pq;
    // priority_queue<int, vector<int>, cmp2<int> > pq;

    // 改成按xx排序
    priority_queue<student, vector<student>, cmp3<student> > pq;
    pq.push(student(1, "张三", 12, 90.5));
    pq.push(student(2, "李四", 21, 91.5));
    pq.push(student(3, "王五", 14, 70.5));
    pq.push(student(4, "孙齐", 18, 91.0));


    // pq.push(4);
    // pq.push(2);
    // pq.push(3);
    // pq.push(5);

    while(!pq.empty())
    {
        showInfo(pq.top());
        pq.pop();
    }
    cout << endl;
}